@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <center>
                <h1>{{ $survey->title }}</h1>
                <h4 style="margin-top: 2rem"> 部门 : {{ $department }} </h4>

            </center>
            <form action="{{ url('staff/submit') }}" method="post">
                {!! csrf_field() !!}
                <input type="hidden" name="survey_id" value="{{ $survey->id }}">
                <input type="hidden" name="department" value="{{ $department }}">


                <hr>

                @foreach ($questions as $question)
                    <div class="panel panel-default">

                        <div class="panel-heading">
                            <h3 class="panel-title">{{ $question->title }}</h3>
                        </div>

                        <div class="panel-body">
                            @if ($question->type != '文本')
                                @foreach($options as $option)
                                    @if($option->question_id == $question->id)
                                        @if($question->type == '单选')
                                            <div class="radio" style="width:95%;padding-left: 4%;">
                                                <label>
                                                    <input type="radio" name="option[{{ $option->question_id }}]" id="" value="{{ $option->id }}_{{ $option->content }}" required="required">
                                                    {{ $option->content }}
                                                </label>
                                            </div>
                                        @elseif($question->type == '多选')
                                            <div class="checkbox" style="width:95%;padding-left: 4%;">
                                                <label>
                                                    <input type="checkbox" name="option[{{ $option->question_id }}][]" value="{{ $option->id }}_{{ $option->content }}">
                                                    {{ $option->content }}
                                                </label>
                                            </div>
                                        @endif
                                    @endif
                                @endforeach
                            @else
                                <div class="form-group">
                                    <textarea name="option[{{ $question->id }}]" placeholder="在这里输入内容..." style="width:100%;height:6rem;resize:none;" class="form-control" required></textarea>
                                </div>
                                <!--<textarea name="option[{$question['id']}]" id="" cols="60" rows="10" style="resize: none"></textarea>-->
                            @endif
                        </div>
                    </div>
                @endforeach

                <center>
                    <button type="submit" id="button_submit" class="btn btn-lg btn-primary" style="margin-bottom: 4rem">提交问卷</button>
                </center>
            </form>
        </div>
    </div>
</div>
@endsection
@section('static-bottom')
<script>
    $('form').submit(function(){
        $('#button_submit').attr('disabled', true);
        setTimeout(function(){
            $('#button_submit').removeAttr('disabled');
        }, 5000);
    })
</script>
@endsection